<?php 
	$posts = $this->getPosts();
    $tool = $this->getToolbar()->setCollection($posts);
    $thumnailWidth = Mage::getStoreConfig('blog/info/thumbnail_width');
    $thumnailHeight = Mage::getStoreConfig('blog/info/thumbnail_height');
    $helper = Mage::helper('cms');
	$helperBlog = Mage::helper('blog');
    $processor = $helper->getBlockTemplateProcessor();
?>
<?php if($posts->count() > 0):?>
<div class="em_post-items">
	<?php foreach ($posts as $post):?>
	<div class="em_post-item">
		<div class="post-title">
				<h2><a href="<?php echo $post->getPostUrl(); ?>" ><?php echo $post->getTitle();?></a></h2>			 
		</div>
		<div class="post-header">
				 <p class="post-by">
				<span class="post-user"><span><?php echo $post->getAuthor()->getUsername(); ?></span></span>
				</p>
				<?php $date = new DateTime($post->getCreatedAt());?>
				<span class="post-time"><small class="time-stamp"><?php echo $date->format('M j Y'); ?></small></span>
				<?php if(!Mage::getStoreConfig('blog/comments_facebook/enabled')):?>
				<span class="comment-count">
					<?php echo $this->getCommentByPost($post->getId())->count(); ?>
				</span>
				<?php else:?>
				<fb:comments-count href=<?php echo $post->getPostUrl(false)?>></fb:comments-count>
				<?php endif;?>
				<a class="comment-post-link" href="<?php echo $post->getPostUrl(); ?>" ><?php echo $this->__('Comments')?></a>
				
		</div>
		<div class="post-image">
			<?php if($post->getImage()):?>
				<a href="<?php echo $post->getPostUrl();?>">
					<img class="img-responsive" src="<?php echo $helperBlog->resizeImage($post->getImage(),$thumnailWidth,$thumnailHeight,"emblog/post",'thumbnail');?>"/>
				</a>
			<?php endif;?>
		</div>
		<div class="post-content">			
			<div class="std">				
				<?php echo $processor->filter($post->getPostIntro());?>
			</div>
            
		</div>	
	</div>
	<?php endforeach; ?>
</div>
<?php echo $tool->toHtml();?>

<?php else:?>
<p class="note-msg"><?php echo $this->__('There are no posts matching the selection.')?></p>
<?php endif;?>